package com.sunny.blog.controller;

import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.io.File;

/**
 * @ClassName: PageController
 * @Description: 页面跳转
 * @Author: sunt
 * @Date: 2020/4/13 10:23
 * @Version 1.0
 **/
@Controller
public class PageController {

    /**
     * 后端页面跳转
     * @param page
     * @return
     */
    @GetMapping("admin/{page}")
    public String toBackPage(@PathVariable String page) {
        return "back" + File.separator + page;
    }

    /**
     * 前端页面跳转
     * @param page
     * @return
     */
    @GetMapping("{page}")
    public String toFrontPage(@PathVariable String page) {
        if(StrUtil.equals("favicon.ico",page)) {
            return "favicon";
        }
        return "front" + File.separator + page;
    }

    /**
     * 错误页面跳转
     * @param page
     * @return
     */
    @GetMapping("/error/{page}")
    public String toErrorPage(@PathVariable String page) {
        return "error" + File.separator + page;
    }
    @GetMapping("/")
    public String toIndexPage() {
        return "front" + File.separator + "index";
    }

    /**
     * 百度验证
     * @return
     */
    @GetMapping("robots.txt")
    public String toRobots() {
        return "robots.txt";
    }

    /**
     * 百度检测
     * @return
     */
    @GetMapping("baidu-verify-7BD568D052.txt")
    public String bdVerify() {
        return "baidu-verify-7BD568D052.txt";
    }


    /**
     * 网站地图
     * @return
     */
    @GetMapping("sitemap.xml")
    public String sitemap() {
        return "sitemap.xml";
    }


    @GetMapping("favicon.ico")
    public String favicon() {
        return "front" + File.separator + "favicon.ico";
    }
}
